﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using HNQXYJ.BLL;
using HNQXYJ.Model;
namespace HNQXYJ.DataCenterJS
{
    public partial class UsersUpdate : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            { 
                int id = Convert.ToInt32(Request["id"]);
                

                Users user = new Users();
                user = new UsersBLL().GetUserDataById(id);
                this.txtUserName.Text = user.UserName;
               // this.txtPwd.Text = user.Password;
                this.txtTrueName.Text = user.TrueName;
                this.txtTouchMehtod.Text = user.TouchMethod;
                this.txtNotes.Text = user.Notes;
            }
        }

        protected void reset_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("UsersGetDataAll.aspx", true);
        }

        protected void add_Click(object sender, ImageClickEventArgs e)
        {
            int id = Convert.ToInt32(Request["id"]);
            Users user = new Users();
            user.ID = id;
            user.UserName = this.txtUserName.Text.Trim();
           // user.Password = this.txtPwd.Text.Trim();
            user.TrueName = this.txtTrueName.Text.Trim();
            user.TouchMethod = this.txtTouchMehtod.Text.Trim();
            user.Notes = this.txtNotes.Text.Trim();
            user.RankName = "000";
            user.RankLevel = "000";

            bool flage = false;
            flage = new UsersBLL().UpdateUserById(user);
            if (flage)
            {
                Response.Redirect("UsersGetDataAll.aspx", true);

            }
            else
            {
                this.Label1.Text = "更新失败";
            }           
        }
    }
}